﻿<%@ Page Title="" Language="VB" MasterPageFile="~/Views/Shared/Base.Master" Inherits="System.Web.Mvc.ViewPage(Of DailyReport.AssessReportModel)" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    AssessReport
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <div style="position: absolute; left: 10px; top: 10px;">
        <%--<ext:Button ID="btnPrint" runat="server" Text="打印" Icon="Printer">
            <Listeners>
                <Click Handler="$('#PrintContent').printArea({ mode: 'popup', popClose: false,strict: true,showTitle: false });" />
            </Listeners>
        </ext:Button>--%>
        <ext:Button ID="btnEx" runat="server" Text="输出Excel" Icon="PageExcel">
            <Listeners>
                <Click Handler="getXlsFromTbl('dataTable',null);" />
            </Listeners>
        </ext:Button>
    </div>
    <div id="PrintContent" class="AssessReport">
        <%Dim _i = 2%>

        <%--↓堆砌表格↓--%>
        <table id="dataTable" border="0" cellpadding="0" cellspacing="0" class="rpgrid" style="font-size:14px;">
            <thead>
                <tr>
                    <th colspan="11" class="title"><h3>
                    工作任务完成情况一览表</h3></th>
                </tr>
                <tr>
                    <th colspan="11" class="date"><%=DailyReport.DailyReportCommon.FormatChineseDate(Now)%></th>
                </tr>
                <tr>
                    <th colspan="7" style="text-align:left;">填报单位：广州市白云区房地产交易登记中心</th>
                    <th colspan="4" style="text-align:right;">单位：面积（平方米） 金额（万元人民币）</th>
                </tr>
                <tr>
                    <th rowspan="2" colspan="2" style="border-top:thin solid #000;border-right:thin solid #000;border-left:thin solid #000;border-bottom:thin solid #000;">
                        房地产评估类别
                    </th>
                    <th rowspan="2" style="border-top:thin solid #000;border-right:thin solid #000;border-bottom:thin solid #000;">
                        栏目
                    </th>
                    <th colspan="4" style="border-top:thin solid #000;border-right:thin solid #000;border-bottom:thin solid #000;">
                        本月统计
                    </th>
                    <th colspan="4" style="border-top:thin solid #000;border-right:thin solid #000;border-bottom:thin solid #000;">
                        本年累计
                    </th>
                </tr>
                <tr>
                    <th style="border-right:thin solid #000;border-bottom:thin solid #000;">
                        宗数
                    </th>
                    <th style="border-right:thin solid #000;border-bottom:thin solid #000;">
                        土地面积
                    </th>
                    <th style="border-right:thin solid #000;border-bottom:thin solid #000;">
                        建筑面积
                    </th>
                    <th style="border-right:thin solid #000;border-bottom:thin solid #000;">
                        房地产价值
                    </th>
                    <th style="border-right:thin solid #000;border-bottom:thin solid #000;">
                        宗数
                    </th>
                    <th style="border-right:thin solid #000;border-bottom:thin solid #000;">
                        土地面积
                    </th>
                    <th style="border-right:thin solid #000;border-bottom:thin solid #000;">
                        建筑面积
                    </th>
                    <th style="border-right:thin solid #000;border-bottom:thin solid #000;">
                        房地产价值
                    </th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td colspan="2" style="border-right:thin solid #000;border-bottom:thin solid #000;border-left:thin solid #000;">
                        <%=Model.Total.assesstype%>
                    </td>
                    <td style="border-right:thin solid #000;border-bottom:thin solid #000;">
                        1
                    </td>
                    <td style="border-right:thin solid #000;border-bottom:thin solid #000;">
                        <%=String.Concat("&nbsp;", Model.Total.assesscount, "&nbsp;")%>
                    </td>
                    <td style="border-right:thin solid #000;border-bottom:thin solid #000;">
                        <%=String.Concat("&nbsp;", Model.Total.landarea, "&nbsp;")%>
                    </td>
                    <td style="border-right:thin solid #000;border-bottom:thin solid #000;">
                        <%=String.Concat("&nbsp;", Model.Total.constructionarea, "&nbsp;")%>
                    </td>
                    <td style="border-right:thin solid #000;border-bottom:thin solid #000;">
                        <%=String.Concat("&nbsp;", Model.Total.constructionprices, "&nbsp;")%>
                    </td>
                    <td style="border-right:thin solid #000;border-bottom:thin solid #000;">
                        <%=String.Concat("&nbsp;", Model.Total.yassesscount, "&nbsp;")%>
                    </td>
                    <td style="border-right:thin solid #000;border-bottom:thin solid #000;">
                        <%=String.Concat("&nbsp;", Model.Total.ylandarea, "&nbsp;")%>
                    </td>
                    <td style="border-right:thin solid #000;border-bottom:thin solid #000;">
                        <%=String.Concat("&nbsp;", Model.Total.yconstructionarea, "&nbsp;")%>
                    </td>
                    <td style="border-right:thin solid #000;border-bottom:thin solid #000;">
                        <%=String.Concat("&nbsp;", Model.Total.yconstructionprices, "&nbsp;")%>
                    </td>
                </tr>
                <%
                    Dim j As Integer
                    For Each at In Model.AssessBaseTypesByName
                        j = 0
                        For Each a In at.AssessItems
                %>
                <tr>
                    <%If j = 0 Then%>
                    <td rowspan="<%=at.AssessItems.Count%>" style="border-right:thin solid #000;border-bottom:thin solid #000;border-left:thin solid #000;">
                        <%=at.AssessBasTypeName%>
                    </td>
                    <%End If%>
                    <td class="assesstype" style="border-right:thin solid #000;border-bottom:thin solid #000;width: 200px;">
                        <%=a.assesstype%>
                    </td>
                    <td style="border-right:thin solid #000;border-bottom:thin solid #000;">
                        <%=_i%>
                    </td>
                    <td style="border-right:thin solid #000;border-bottom:thin solid #000;">
                        <%=String.Concat("&nbsp;", a.assesscount, "&nbsp;")%>
                    </td>
                    <td style="border-right:thin solid #000;border-bottom:thin solid #000;">
                        <%=String.Concat("&nbsp;", a.landarea, "&nbsp;")%>
                    </td>
                    <td style="border-right:thin solid #000;border-bottom:thin solid #000;">
                        <%=String.Concat("&nbsp;", a.constructionarea, "&nbsp;")%>
                    </td>
                    <td style="border-right:thin solid #000;border-bottom:thin solid #000;">
                        <%=String.Concat("&nbsp;", a.constructionprices, "&nbsp;")%>
                    </td>
                    <td style="border-right:thin solid #000;border-bottom:thin solid #000;">
                        <%=String.Concat("&nbsp;", a.yassesscount, "&nbsp;")%>
                    </td>
                    <td style="border-right:thin solid #000;border-bottom:thin solid #000;">
                        <%=String.Concat("&nbsp;", a.ylandarea, "&nbsp;")%>
                    </td>
                    <td style="border-right:thin solid #000;border-bottom:thin solid #000;">
                        <%=String.Concat("&nbsp;", a.yconstructionarea, "&nbsp;")%>
                    </td>
                    <td style="border-right:thin solid #000;border-bottom:thin solid #000;">
                        <%=String.Concat("&nbsp;", a.yconstructionprices, "&nbsp;")%>
                    </td>
                </tr>
                <%
                    j += 1
                    _i += 1
                Next
            Next
                %>
                <tr>
                    <td colspan="2" style="text-align:left;">负责人：余颖斌</td>
                    <td colspan="8" style="text-align:left;">填报人：<%=DailyReport.DailyReportCommon.CurrentUserName%></td>
                    <td style="text-align:right;">填报日期：<%=Now.ToString("yyyy.MM.dd")%></td>
                </tr>
            </tbody>
        </table>
        <%--↑堆砌表格↑--%>
    </div>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="HeaderArea" runat="server">
    <script type="text/javascript" language="javascript">
        function getXlsFromTbl(inTblId, inWindow) {
            try {
                var allStr = "";
                var curStr = "";
                //alert("getXlsFromTbl"); 
                if (inTblId != null && inTblId != "" && inTblId != "null") {
                    //curStr = getTblData(inTblId, inWindow);
                    curStr = getTblHTML(inTblId, inWindow);
                }
                if (curStr != null) {
                    allStr += curStr;
                }
                else {
                    alert("你要导出的表不存在！");
                    return;
                }
                var fileName = getExcelFileName();
                doFileExport(fileName, allStr);
            }
            catch (e) {
                alert("导出发生异常:" + e.name + "->" + e.description + "!");
            }
        }
        function getTblData(inTbl, inWindow) {
            var rows = 0;
            //alert("getTblData is " + inWindow); 
            var tblDocument = document;
            if (!!inWindow && inWindow != "") {
                if (!document.all(inWindow)) {
                    return null;
                }
                else {
                    tblDocument = eval(inWindow).document;
                }
            }
            var curTbl = tblDocument.getElementById(inTbl);
            var outStr = "";
            if (curTbl != null) {
                for (var j = 0; j < curTbl.rows.length; j++) {
                    //alert("j is " + j); 
                    for (var i = 0; i < curTbl.rows[j].cells.length; i++) {
                        //alert("i is " + i); 
                        if (i == 0 && rows > 0) {
                            outStr += " \t";
                            rows -= 1;
                        }
                        outStr += curTbl.rows[j].cells[i].innerText + "\t";
                        if (curTbl.rows[j].cells[i].colSpan > 1) {
                            for (var k = 0; k < curTbl.rows[j].cells[i].colSpan - 1; k++) {
                                outStr += " \t";
                            }
                        }
                        if (i == 0) {
                            if (rows == 0 && curTbl.rows[j].cells[i].rowSpan
) {
                                rows = curTbl.rows[j].cells[i].rowSpan - 1;
                            }
                        }
                    }
                    outStr += "\r\n";
                }
            }
            else {
                outStr = null;
                alert(inTbl + "不存在!");
            }
            return outStr;
        }

        function getTblHTML(inTbl, inWindow) {
            var rows = 0;
            //alert("getTblData is " + inWindow); 
            var tblDocument = document;
            if (!!inWindow && inWindow != "") {
                if (!document.all(inWindow)) {
                    return null;
                }
                else {
                    tblDocument = eval(inWindow).document;
                }
            }
            var curTbl = tblDocument.getElementById(inTbl);
            var outStr = "";
            if (curTbl != null) {
                outStr = curTbl.outerHTML;
            }
            else {
                outStr = null;
                alert(inTbl + "不存在!");
            }
            return outStr;
        }

        function getExcelFileName() {
            var d = new Date();
            var curYear = d.getYear();
            var curMonth = "" + (d.getMonth() + 1);
            var curDate = "" + d.getDate();
            var curHour = "" + d.getHours();
            var curMinute = "" + d.getMinutes();
            var curSecond = "" + d.getSeconds();
            if (curMonth.length == 1) {
                curMonth = "0" + curMonth;
            }
            if (curDate.length == 1) {
                curDate = "0" + curDate;
            }
            if (curHour.length == 1) {
                curHour = "0" + curHour;
            }
            if (curMinute.length == 1) {
                curMinute = "0" + curMinute;
            }
            if (curSecond.length == 1) {
                curSecond = "0" + curSecond;
            }
            var fileName = "工作任务完成情况一览表" + "_" + curYear + curMonth + curDate + ".xls";
            //alert(fileName); 
            return fileName;
        }
        function doFileExport(inName, inStr) {
            var xlsWin = null;
            if (!!document.all("glbHideFrm")) {
                xlsWin = glbHideFrm;
            }
            else {
                var width = 6;
                var height = 4;
                var openPara = "left=" + (window.screen.width / 2 - width / 2)
                + ",top=" + (window.screen.height / 2 - height / 2)
                + ",scrollbars=no,width=" + width + ",height=" + height;
                xlsWin = window.open("", "_blank", openPara);
            }
            xlsWin.document.write(inStr);
            xlsWin.document.close();
            xlsWin.document.execCommand('Saveas', true, inName);
            xlsWin.close();
        } 

    </script>

    <script language="javascript" type="text/javascript">
        

    </script>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="StartupArea" runat="server">
</asp:Content>
